package com.stx.openeyes.view.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.jaeger.library.StatusBarUtil;
import com.stx.openeyes.R;
import com.stx.openeyes.adapter.MyVideoItemAdapter;
import com.stx.openeyes.adapter.NavigationItemAdapter;
import com.stx.openeyes.dto.Response;
import com.stx.openeyes.model.Video;
import com.stx.openeyes.utils.ContextUtil;
import com.stx.openeyes.utils.HttpAdress;
import com.stx.openeyes.utils.NToast;
import com.stx.openeyes.view.fragment.HotFragment;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import okhttp3.Call;

public class NavigationActivity extends AppCompatActivity {

    private static final String TAG = "NavigationActivity";
    protected Context mContext;
    @BindView(R.id.video_item_listview)
    ListView lvHome;

    private NavigationItemAdapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_video_list_view);
        StatusBarUtil.setTranslucent(this);
        ButterKnife.bind(this);
        mContext = this;
        setToolBar();
        setLvAdapter();

        setListener();
    }

    List<String> listAll = new ArrayList<String>();

    private void setLvAdapter() {
        listAll.addAll(Arrays.asList(HotFragment.TITLE));
        mAdapter = new NavigationItemAdapter(mContext, listAll);
        lvHome.setAdapter(mAdapter);
        if (mAdapter != null) {
            mAdapter.notifyDataSetChanged();
        }
    }

    private void setToolBar() {
        Toolbar tb = (Toolbar) findViewById(R.id.tb_my_recommend);
        setSupportActionBar(tb);
        ActionBar supportActionBar = getSupportActionBar();
        supportActionBar.setDisplayShowTitleEnabled(false);
        supportActionBar.setDisplayHomeAsUpEnabled(true);
        tb.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        TextView titleTv = (TextView) findViewById(R.id.vide_item_tv_title);
        titleTv.setText("导航");
    }

    private void setListener() {
        lvHome.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String data = listAll.get(position);
                ContextUtil.tabIndex = position;
                finish();
            }
        });
    }

    @Override
    public void onBackPressed() {
        finish();
    }

}
